<?php
$connect = mysqli_connect('localhost','root','root','thinkcmf');
mysqli_set_charset($connect,'utf8');
if(!$connect){
    echo '数据库连接失败';
    die;
}

$image = $_POST['image'];
$name = $_POST['name'];
$age = $_POST['age'];
$sex = $_POST['sex'];
$idcard = $_POST['idcard'];
$address = $_POST['address'];

$sql = "insert into cmf_student 
    (image,name,age,sex,idcard,address) 
    values ('$image','$name',$age,$sex,'$idcard','$address')";

$query = mysqli_query($connect, $sql);

if ($query) {
    echo json_encode(['code' => 1, 'msg' => '添加成功', 'data' => []]);
} else {
    echo json_encode(['code' => 2, 'msg' => '添加失败', 'data' => []]);
}